{extends file='include/base_with_menu.tpl'}

{block name="external_javascript"}
<script type="text/javascript" src="/scripts/jquery-ui/jquery.ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="/scripts/oa_calendar.js"></script>
{/block}

{block name="javascript"}
<script type="text/javascript">
(function($) {
    $(function() {
        $('.normal_catagory').change(function() {
            $('.perm_catagory').val('');
        });

        $('.perm_catagory').change(function() {
            $('.normal_catagory').val('');
        });

        $('#birthday').datepicker();

    });
})(jQuery);
</script>
{/block}

{block name='content'}
<h3 class="blockTitle">编辑帐号</h3>
<div class="layout">
<form method="post" action="/perm/user/user/edit">
    <table width="100%" class="tbLayout01" cellspacing="0" cellpadding="0">
        <tr>
            <td class="textRight">工号:</td>
            <td class="textLeft"><span>{$user.id|ytuid}</span></td>
        </tr>
        <tr>
            <td class="textRight">姓名:</td>
            <td class="textLeft"><span>{$user.name|escape}</span></td>
        </tr>
        <tr>
            <td class="textRight">用户名:</td>
            <td class="textLeft"><span>{$user.username|default:''|escape}</span></td>
        </tr>
        <tr>
            <td class="textRight">邮箱:</td>
            <td class="textLeft">
                <input type="text" class="txt01" name="email" value="{$user.email|escape}" />
                <span class="cGray">(用户常用联系电子邮箱)</span>
            </td>
        </tr>
        <tr>
            <td class="textRight">性别:</td>
            <td class="textLeft">
                <input type="radio" name="gender" value="" checked="checked" />不详&nbsp;
            {foreach $gender_setting as $id => $title}
                <input type="radio" name="gender" value="{$id}" {if $user.gender !== NULL && $id == $user.gender}checked="checked"{/if} />{$title}&nbsp;
            {/foreach}
            </td>
        </tr>
        <tr>
            <td class="textRight">生日:</td>
            <td class="textLeft">
                <input type="text" class="txt01" id="birthday" name="birthday" value="{$user.birthday}" />
            </td>
        </tr>
        <tr>
            <td class="textRight">部门:</td>
            <td class="textLeft">
                <select name="department_id">
                {foreach $department_info as $info}
                    <option value="{$info.id}" {if $user.department_id == $info.id}selected="selected"{/if}>{$info.name|escape}</option>
                {/foreach}
                </select>
            </td>
        </tr>
        <tr>
            <td class="textRight">权限:</td>
            <td class="textLeft">
            {foreach $role_dict as $catagory_id => $info}
                {if $catagory_id == $perm_catagory_id}
                    {continue}
                {/if}
                {$catagory_dict[$catagory_id]}权限:
                <select class="normal_catagory" name="user_role[]">
                    <option value="">--请选择--</option>
                {foreach $info as $role}
                    <option value="{$role.id}" {if in_array($role.id, $user_role_list)}selected="selected"{/if}>{$role.title|escape}</option>
                {/foreach}
                </select>
                <br /><br />
            {/foreach}
            {if $SESSION->is_master()}
                管理权限:
                <select class="perm_catagory" name="user_role[]">
                    <option value="">--请选择--</option>
                    {foreach $role_dict[$perm_catagory_id] as $role}
                    <option value="{$role.id}" {if in_array($role.id, $user_role_list)}selected="selected"{/if}>{$role.title|escape}</option>
                    {/foreach}
                </select>
                <br />
                <span class="cGray">(设置管理权限后，上面的权限设置失效；同样，设置上面的权限后，管理权限失效)</span>
            {/if}
            </td>
        </tr>
        <tr>
            <td class="textRight">&nbsp;</td>
            <td class="textLeft">
                <input type="submit" value="修改" />&nbsp;&nbsp;&nbsp;
                <input type="button" value="取消" onclick="javascript:window.history.back();" />
            </td>
        </tr>
    </table>
    <input type="hidden" name="u_id" value="{$user.id}" />
    <input type="hidden" name="{$token_name}" value="{$token_hash}" />
    <input type="hidden" name="return_url" value="{$return_url|default:''}" />
</form>
</div>
{/block}
